﻿using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BaseUi.Views.PlcView
{
    /// <summary>
    /// ColdBoxTakeThreeView.xaml 的交互逻辑冷库取放点3页面
    /// </summary>
    public partial class ColdBoxTakeThreeView : UserControlBase
    {
        public ColdBoxTakeThreeView()
        {
            InitializeComponent();
        }

        private void loadFirst(object sender, EventArgs e)
        {
            if (this.IsInDesignMode)
                return;

            LoadTask();
        }

        private void LoadTask()
        {
            var ioi = LocalStatic.Plc.Read<float>("1290");
            if (ioi.IsSucceed==false)
            {
                ColdthBox1g1.Text = "未接收";
            }
            else
            {
                ColdthBox1g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1292");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g2.Text = "未接收";
            }
            else
            {
                ColdthBox1g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1294");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g3.Text = "未接收";
            }
            else
            {
                ColdthBox1g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1296");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g4.Text = "未接收";
            }
            else
            {
                ColdthBox1g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1298");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g5.Text = "未接收";
            }
            else
            {
                ColdthBox1g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1300");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g6.Text = "未接收";
            }
            else
            {
                ColdthBox1g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1302");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g7.Text = "未接收";
            }
            else
            {
                ColdthBox1g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1304");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g8.Text = "未接收";
            }
            else
            {
                ColdthBox1g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1306");
            if (ioi.IsSucceed == false)
            {
                ColdthBox1g9.Text = "未接收";
            }
            else
            {
                ColdthBox1g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1308");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g1.Text = "未接收";
            }
            else
            {
                ColdthBox2g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1310");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g2.Text = "未接收";
            }
            else
            {
                ColdthBox2g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1312");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g3.Text = "未接收";
            }
            else
            {
                ColdthBox2g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1314");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g4.Text = "未接收";
            }
            else
            {
                ColdthBox2g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1316");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g5.Text = "未接收";
            }
            else
            {
                ColdthBox2g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1318");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g6.Text = "未接收";
            }
            else
            {
                ColdthBox2g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1320");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g7.Text = "未接收";
            }
            else
            {
                ColdthBox2g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1322");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g8.Text = "未接收";
            }
            else
            {
                ColdthBox2g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1324");
            if (ioi.IsSucceed == false)
            {
                ColdthBox2g9.Text = "未接收";
            }
            else
            {
                ColdthBox2g9.Text = ioi.Value.ToString();
            }

            //ColdthBox1g1.Text= LocalStatic.Plc.Read<float>("1290").Value.ToString();
            //ColdthBox1g2.Text = LocalStatic.Plc.Read<float>("1292").Value.ToString();
            //ColdthBox1g3.Text = LocalStatic.Plc.Read<float>("1294").Value.ToString();
            //ColdthBox1g4.Text = LocalStatic.Plc.Read<float>("1296").Value.ToString();
            //ColdthBox1g5.Text = LocalStatic.Plc.Read<float>("1298").Value.ToString();
            //ColdthBox1g6.Text = LocalStatic.Plc.Read<float>("1300").Value.ToString();
            //ColdthBox1g7.Text = LocalStatic.Plc.Read<float>("1302").Value.ToString();
            //ColdthBox1g8.Text = LocalStatic.Plc.Read<float>("1304").Value.ToString();
            //ColdthBox1g9.Text = LocalStatic.Plc.Read<float>("1306").Value.ToString();
            //ColdthBox2g1.Text = LocalStatic.Plc.Read<float>("1308").Value.ToString();
            //ColdthBox2g2.Text = LocalStatic.Plc.Read<float>("1310").Value.ToString();
            //ColdthBox2g3.Text = LocalStatic.Plc.Read<float>("1312").Value.ToString();
            //ColdthBox2g4.Text = LocalStatic.Plc.Read<float>("1314").Value.ToString();
            //ColdthBox2g5.Text = LocalStatic.Plc.Read<float>("1316").Value.ToString();
            //ColdthBox2g6.Text = LocalStatic.Plc.Read<float>("1318").Value.ToString();
            //ColdthBox2g7.Text = LocalStatic.Plc.Read<float>("1320").Value.ToString();
            //ColdthBox2g8.Text = LocalStatic.Plc.Read<float>("1322").Value.ToString();
            //ColdthBox2g9.Text = LocalStatic.Plc.Read<float>("1324").Value.ToString();
        }

        private void coldthboxButton_Click(object sender, RoutedEventArgs e)
        {
            LoadTask();
        }

        private void Label_ColdthBoxDoubleClick1g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1290", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1292", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1294", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1296", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1298", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1300", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1302", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g8(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g8.Text);
                var ioi = LocalStatic.Plc.Write<float>("1304", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick1g9(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox1g9.Text);
                var ioi = LocalStatic.Plc.Write<float>("1306", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1308", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1310", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1312", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1314", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1316", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1318", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1320", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g8(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g8.Text);
                var ioi = LocalStatic.Plc.Write<float>("1322", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdthBoxDoubleClick2g9(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdthBox2g9.Text);
                var ioi = LocalStatic.Plc.Write<float>("1324", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }
    }
}
